﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;


namespace WFP_Sandbox.ViewModel
{
    public class PlayerResult: Player
    {
        private ObservableCollection<GameResult> mGameResults;

        public ObservableCollection<GameResult> GameResults
        {
            get { return mGameResults; }
            set
            {
                mGameResults = value;
                RaisePropertyChangedEvent("GameResults");
            }
        }

        public PlayerResult (List<GameResult> pGameResults, Player pPlayer )
        {
            Name = pPlayer.Name;
            TeeNumber = pPlayer.TeeNumber;
            Sport = pPlayer.Sport;
            GameResults = new ObservableCollection<GameResult>(pGameResults);

        }


        public String ContainsResultForGame(string mGameNumber)
        {

            var tmpResults = GameResults.Where(p => p.GameNumber == mGameNumber);
            if (tmpResults.FirstOrDefault() == null)
                return "";
            return tmpResults.First().GameNumber;
        }
    }
}
